<?php
/**
 * Created by PhpStorm.
 * User: 76683
 * Date: 2018/7/16
 * Time: 23:40
 */

namespace app\sd\admin;


use app\admin\controller\Admin;
use app\common\builder\ZBuilder;
use app\sd\model\WeCategory as WeCategoryModel;

class WeCategory extends Admin
{
    public function index(){
        $map = $this->getMap();
        $data_list = WeCategoryModel::where(array_merge($map,['is_delete'=>0]))->paginate();
        $fields = [
            ['text','name','领域名称'],
            ['select','status','状态','请选择 禁用 or 启用，默认启用',[0=>'禁用',1=>'启用'],1],
            ['select','is_verify','是否审核通过','请选择 通过 or 不予通过,默认通过审核',[0=>'不予通过',1=>'通过'],1],
            ['hidden','create_time',time()],
            ['hidden','update_time',time()]
        ];
        $columns = [
            ['id','ID'],
            ['name','领域名称'],
            ['status','状态','switch'],
            ['is_verify','是否审核通过','switch'],
            ['create_time','创建时间','datetime'],
            ['update_time','更新时间','datetime'],
            ['right_button','操作','btn']
        ];
        return ZBuilder::make('table')
            ->setSearch(['name'=>'领域名称'])
            ->addColumns($columns)
            ->autoAdd($fields,'we_category')
            ->addRightButtons('delete')
            ->setRowList($data_list)
            ->setTableName('we_category')
            ->fetch();
    }
}